#ifndef GLWIDGET_H
#define GLWIDGET_H

#include <oopgl_base/GlString.h>
#include "GlAction.h"
#include "GlGuiEvent.h"
#include "GlWidgetStyle.h"
#include <vector>

using namespace std;



class GlActionChain;


/**************************************************************************************************
 * <summary>  Gl widget.  </summary>
 *
 * <remarks>  Deng Nianchen, 2011/3/21. </remarks>
 **************************************************************************************************/

class GlWidget
{

private:

  GlWidget * _pParent;
  vector< GlWidget * > _pChildren;
  vector< GlActionChain * > _pBasicActionChains;
  vector< GlActionChain * > _pCustomActionChains;

  void _appendChild (GlWidget * pWidget); 

public:

  /**************************************************************************************************
   * <summary> Construct a widget object and append it to the parent widget. </summary>
   *
   * <remarks> Deng Nianchen, 2011/3/21. </remarks>
   *
   * <param name="pParent"> Pointer to the parent widget. </param>
   **************************************************************************************************/

  GlWidget (GlWidget * pParent);


  virtual ~GlWidget ();


  virtual void draw () const;

  /**************************************************************************************************
   * <summary>  Bind an action to event. </summary>
   *
   * <remarks>  Deng Nianchen, 2011/3/21. </remarks>
   *
   * <param name="eventType"> Type of the event. </param>
   * <param name="pAction"> Pointer to the action. </param>
   **************************************************************************************************/

  void addAction (int eventType, GlAction * pAction); 

  /**************************************************************************************************
   * <summary>  Register related actions to the event. </summary>
   *
   * <remarks>  Deng Nianchen, 2011/3/21. </remarks>
   *
   * <param name="event"> The gui event object. </param>
   **************************************************************************************************/

  void registerActionsTo (GlGuiEvent & event); 



  GlString getTitle () const;
  void setTitle (const GlString & title);
  const GlWidgetStyle & getStyle () const;
  GlWidgetStyle & getStyle ();
  void setStyle (const GlWidgetStyle & style);
  const vector< GlWidget * > & getChildren () const;
  vector< GlWidget * > & getChildren ();


  const int MOUSE_OUT = 0, MOUSE_IN = 1, MOUSE_OVER = 2;
  const int MOUSE_DOWN = 3, MOUSE_UP = 4;
  const int MOUSE_DRAG_IN = 5, MOUSE_DRAG_OUT = 6, MOUSE_DRAG_OVER = 7;
  const int MOUSE_WHEEL_ROLL = 8;

};  //end class GlWidget


#endif